<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/26
 * Time: 19:03
 */
//phpinfo();

$pdo=new PDO("mysql:dbname=text09251;host=127.0.0.1","root");
$pdo->exec("SET NAMES 'utf8';");
$sql="SELECT * FROM tb_user;";

$sql1="SELECT * FROM dc_comment u NATURAL LEFT JOIN tb_user p;";


echo "<table border='1' >";

echo "<tr>
<th>名字</th>
<th>编号</th>
<th>电话</th>
<th>性别</th>
<th>年龄</th>
</tr>";

foreach ($pdo->query($sql) as $user){
    //var_dump($user);
    //echo "<br>";
    echo "<tr>";
    //把数据显示到表格中
//    var_dump($user['name']);
    echo "<td>{$user['name']}</td>";
    echo "<td>{$user['namber']}</td>";
    echo "<td>{$user['tel']}</td>";
    echo "<td>{$user['sex']}</td>";
    echo "<td>{$user['age']}</td>";
    echo "</tr>";
}





echo "<table border='1' >";

echo "<tr>
<th>名字</th>
<th>编号</th>
<th>电话</th>
<th>性别</th>
<th>年龄</th>
</tr>";


foreach ($pdo->query($sql1) as $user){
    //var_dump($user);
    //echo "<br>";
    echo "<tr>";
    //把数据显示到表格中
//    var_dump($user['name']);
    echo "<td>{$user['name']}</td>";
    echo "<td>{$user['namber']}</td>";
    echo "<td>{$user['tel']}</td>";
    echo "<td>{$user['sex']}</td>";
    echo "<td>{$user['age']}</td>";
    echo "</tr>";
}






